<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="180px">
      <el-card class="box-card" style="margin-top: 20px">
        <div style="width: 150px; height: 10px; background-color: var(--primary-color);position:relative;top:-15px"></div>
        <div class="title20Class">
          <svg-icon icon-class="info" class="svgClass"/>
          基本信息
        </div>
        <el-divider content-position="left"></el-divider>
        <el-row>
          <el-col :span="12">
            <el-form-item label="岗位名称" prop="postName">
              <el-input size="small" v-model="form.postName" placeholder="请输入内容"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <div class="dialog-footer" style="text-align: center; margin-top: 10px">
        <el-button size="small" @click="cancel">取 消</el-button>
        <el-button size="small" type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
import {
  addRisk,
  deptTreeSelect
} from '@/api/lc/risk'

import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import ChooseProcess from '@/plugins/package/tree/chooseProcess'
import ChooseDept from '@/plugins/package/tree/chooseDept'
import { addPost, optionselect, updatePost } from '@/api/system/post'

export default {
  name: 'postUpdate',
  data() {
    return {
      form: {
        postName: this.$route.params.label,
        postId: this.$route.params.deptId
      },
      rules: {
        postName: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {},
  created() {
  },
  methods: {
    // 取消按钮
    cancel() {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$router.go(-1)
    },
    /** 提交按钮 */
    submitForm: function() {
      console.log(this.form)
      this.$refs['form'].validate(valid => {
        if (valid) {
          updatePost(this.form).then(response => {
            this.$modal.msgSuccess('修改成功')
            this.$store.dispatch('tagsView/delView', this.$route)
            this.$router.go(-1)
          })
        }
      })
    }
  }
}
</script>
